lapis = require "lapis"
import respond_to from require "lapis.application"
import Model from require "lapis.db.model"

class User extends Model
    @table_name:=> "users"

class UserApplication extends lapis.Application

    @enable "etlua"

    [user_new:"/user/new"]: =>
        render: true

    [user_list: "/user/list"]: =>
        @users = User\select!
        render: true 
        
    [user_new:"/user/new"]: =>
        render: true

    [user_create: "/user/create"]: respond_to {
        POST: =>
            user = User\create{
                name: @params.name
                sex: @params.sex
                age: @params.age
                profession: @params.profession
                habits: @params.habits
                study: @params.study
                note: @params.note
                page: @params.page
            }
            @users = User\select!
            render: "user_list"
    }
